package test;

import java.util.Scanner;

public class 飞机票2 {
    public static void main(String[] args) {
        // 负责录入
        Scanner sc = new Scanner(System.in);
        System.out.println("原票价：");
        int fare = sc.nextInt();
        System.out.println("月份：");
        int month = sc.nextInt();
        System.out.println("头等舱输入1，经济舱输入2");
        int sum = sc.nextInt();

        // 负责计算
        double result = calculate(fare, month, sum);
        System.out.println("最终票价为：" + result);
    }

    /**
     * 本方法用于计算飞机票的实际价格
     * @param fare  原价
     * @param month 月份
     * @param sum   舱位的级别
     * @return      现价
     */
    public static double calculate(int fare, int month, int sum) {
        double result = 0;
        // 判断
        if (month >= 5 && month <= 10) {
            if (sum == 1) {
                result = fare * 0.9;
            } else {
                result = fare * 0.85;
            }
        } else {
            if (sum == 1) {
                result = fare * 0.7;
            } else {
                result = fare * 0.65;
            }
        }
        return result;
    }
}